#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>

#ifndef MY_OBJ_H
#define MY_OBJ_H

//信号量
class m_sems
{

public:
    m_sems();
    m_sems(int s_nums);
    ~m_sems();
    int get_semid();
    void p_sem(int semid, int semnum);
    void v_sem(int semid, int semnum);
    void init_sem(int semid, int semnum, int value);

private:
    int semid;
};


//共享内存
class m_shm
{
public:
    m_shm(int size);
    ~m_shm();
    int get_shmid();
    char *get_shmaddr();
    void  shm_copy(char*buffer);
private:
    int shmid;
    char *shmaddr;
};
//消息队列
class m_msg
{
public:
    m_msg();
    int m_msgsed( char *msgbuf, int msgflg=0);
    int m_msgget(char*msgbuf,int msgtype,int msgflg=0);
    ~m_msg();
private:
    int msgid;
};
//管道
class m_fifo
{
public:
    m_fifo( char *path, mode_t mode);
    ~m_fifo();
    int m_open(char *pathname,int flags);
    int m_close(int fd);
    int m_read(int fd,char *buf,int size);
    int m_write(int fd,char *buf,int size);
    int m_unlink(char *pathname);
private:
    int fd;
    char *pathname;
    mode_t mode;
};


#endif // MY_OBJ_H